package ControlLayer;
 
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported
/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class DVDCtr
{
    
    
    //declare instance variables to reference containers
    //passed as arguments from the main class
    private DVDCon dvdCon;
    private static DVDCtr instance;
        
    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()//DVD container is to be passed as parameter from the main controller
    {
        dvdCon = dvdCon.getInstance();
    }
    
     /**
     * Singleton method for working with only one instance of AddressCtr.
     * (not strictly necessary for controller classes (as it is for containerclasses) but might still be convenient.)
     */
    public static  DVDCtr getInstance()
    {
        if (instance == null)
        {
            instance = new DVDCtr();
        }
        return instance;
    }
    
    /**
     * Returns an object of type DVD
     */
    public DVD getDVD(long id)
    {
        return dvdCon.getDVD(id);    
    }    
    
    /**
     * creates a new instance of DVD and adds it to the containerclass
     */
    public void createDVD(String newTitle, String newArtist, String newReleaseDate)
    {
         dvdCon.addDVD(newTitle, newArtist, newReleaseDate);
    }
    
      /**
     *  Removes a DVD from the containerclass.
     */
    public void deleteDVD(long id)
    {
        dvdCon.deleteDVD(id);
    }
    
    /**
     * creates a new instance of Copy
     */
    public void createCopy(long newId, String newPurchaseDate, int newPurchasePrice)
    {
        dvdCon.addCopy(newId, newPurchaseDate, newPurchasePrice);
    }
    
    /**
    * prints a list of all dvds registered in the system
    *(print methods maybe should have been called at UI-level 
    * on a returned object instead, but time caught up on us :-) )
    */
    public void listAllDvds()
    {
          dvdCon.getDVDCon();
    }
    
    /**
    * returns a list of all persons registered in the system
    */
    public ArrayList<Copy> getAllCopies()
    {
       return dvdCon.getInstance().getAllCopies();
    }
}







